﻿<link href="../../Content/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="../../Content/Styles/button.css" rel="stylesheet" type="text/css" />
<link href="../../Content/Styles/login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
    //even đóng dialog khi click vào nút đóng
    $('.closelogin').click(function (e) {
        //hủy bỏ các link liên kết,"bỏ dấu #"
        e.preventDefault();
        //đóng thẻ dialog
        $("#dialog").fadeOut(500);
        //đóng thẻ nền dialog
        $("#dialog_nen").fadeOut(500);
        var url = window.location.href;
        if (url.indexOf("CreateStep1") != -1) {
            window.location.href = "/Home/Index";
        }

    });
    $(document).keydown(function (e) {
        // ESCAPE key pressed
        if (e.keyCode == 27) {
            //hủy bỏ các link liên kết,"bỏ dấu #"
            e.preventDefault();
            //đóng thẻ dialog
            $("#dialog").fadeOut(500);
            //đóng thẻ nền dialog
            $("#dialog_nen").fadeOut(500);
        }
    });

</script>
<style type="text/css">
    #forgotpassform
    {
        width: 335px;
        background-color: white;
        clear: both;
        overflow: hidden;
        padding: 15px 5px 15px 10px;
        margin-left: auto;
        margin-right: auto;
        border: 4px solid #EAEAEA;
        border-top: none;
        @*min-height: 170px;*@
        position: relative;
    }
</style>
<div id="Container" style="position: relative">
    <div id="forgotpassform" class="rounded-corners">
        <div id="headform" style=" height: 30px">
            <label style="margin-left: 12px;">Your Email</label>
            <div style="float: right; margin-right: 1px">
                <a href="#">
                    <img src="./../../Content/images/icons/close.png" class="closelogin" width="30px"
                         height="30px" style="position: absolute;right: 10px;top: 5px;" /></a>
            </div>
        </div>
        <div class="logfield">
            <input id="emailfgpassword" class="login-field" type="text" />
        </div>
        <div id="erroremail" style="display: none;color:darkred;margin-left: 15px;margin-bottom: 10px;">
        </div>
        <p style="margin-left: 15px">
            <input id="fgpassbtn" type="submit" class="small button green" style="width: 75px;
                height: 30px; color: white !important" value="Submit" />
            <input type="reset" class="small button green" style="margin-left: 5px; width: 75px;
                height: 30px; color: white !important" value="Reset" id="resetbtn" />
        </p>
        
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        document.getElementById('emailfgpassword').focus();
        $("#fgpassbtn").click(function () {
            var emailfgpw = $('input#emailfgpassword').val();
            var url = window.location.href;
            if (emailfgpw == "") {
                $("div#erroremail").css("display", "block");
                $("div#erroremail").html("Please input email!");
            } else { //call ajax function here
                $.ajax({
                    url: "/Users/Checkmailforgotpass",
                    type: 'POST',
                    data: { email: emailfgpw },
                    success: function (response) {
                        //alert(response);
                        if (response == "NotExist") {
                            $("div#erroremail").css("display", "block");
                            $("div#erroremail").html("Sorry,this email isn't exist");

                        } else {
                            
                            $("#dialog").fadeOut(300);
                            //đóng thẻ nền dialog
                            $("#dialog_nen").fadeOut(300);
                            history.go(0);
                        }
                    }
                });
            }
        });

        $('#resetbtn').click(function () {
            document.getElementById('emailfgpassword').value = '';
        });
    })
</script>
